package io.github.lingalone.monsterauth.controller;


import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 描述：
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/5/21 11:03
 */
@Controller
public class LoginController {


    @RequestMapping("/")
    @ResponseBody
    public String home() {
        return "index";
    }

    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return "login";
    }

    @RequestMapping("/login")
    public String login() {
        return "login";
    }

    @PostMapping(value = "/login")
    public String login(String username, String password, String redirect, Model model) {
        if(StringUtils.isNotBlank(redirect))
            return "redirect:" + redirect;
        else
            return "redirect:hello1";
    }

}
